import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "../component" as C
import "qrc:/component/ZGlobal.js" as Global
C.ZModelRect {
    id: rootAutoPage
    radius: 20
    clip: true
    width:800
    height:510
    visible: false
    Image {
        anchors.fill: parent
        source: "qrc:/assets/auto_bg.png"
        fillMode: Image.PreserveAspectCrop
        layer.enabled: true

        Image {
            x: 40
            y: 40
            source: "qrc:/assets/greenrect.png"
            width: 16
            height: 28
            fillMode: Image.PreserveAspectFit
        }

        Label{
            x:68
            y:36
            Text{
                text: "生产信息"
                font.pixelSize: 28
                color: "#333333"
                font.bold: true
            }
        }

        Label{
            x:40
            y:108
            Text{
                text: "产品名称"
                font.pixelSize: 24
                color: "#333333"
            }
        }


        C.ZInputImage{
            id: productName
            x:40
            y:151
            placeholderText: "请输入产品名称"
            onTextChanged: {
                console.log("text:>>>", text);
            }
        }

        Label{
            x:40
            y:252
            Text{
                text: "生产车间"
                font.pixelSize: 24
                color: "#333333"
            }
        }

        C.ZInputImage{
            id: workshopName
            x:40
            y:295
            placeholderText: "请输入生产车间"
            onTextChanged: {
                console.log("text:>>>", text);
            }
        }

        Label{
            x:40
            y:380

            Text{
                id: errInfo
                text: "请输入正确的注册码"
                font.pixelSize: 20
                color: "red"
                visible: false
            }
        }

        C.ZButton{
            x: 328
            y: 400
            text: "取消"
            onClicked: {
                // console.log(">>>>>>>>>>>>")
                rootAutoPage.visible=false;
                rootMainPage.hideMask("cancel");
            }
        }


        C.ZButton{
            x: 560
            y: 400
            text: "确定"
            color: "#178FCD"
            fontColor: "white"
            onClicked: {
                errInfo.text="";

                do{
                    if (productName.text.length === 0){
                        errInfo.text = "请输入产品名称"
                        break;
                    }

                    if (workshopName.text.length === 0){
                        errInfo.text = "请输入生产车间"
                        break;
                    }

                }while(0);
                if (errInfo.text.length > 0){
                    errInfo.visible = true;
                    return;
                }
                batchInfo.addBatch(productName.text, workshopName.text)
                rootAutoPage.visible=false
                rootMainPage.hideMask("ok");
            }
        }
    }

}

